package cn.xhy.module.purchase.service.listener;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.mq.redis.core.stream.AbstractRedisStreamMessageListener;
import cn.iocoder.yudao.module.bpm.event.CgBpmProcessInstanceStatus;
import cn.xhy.module.purchase.service.materialdemand.MaterialDemandService;
import cn.xhy.module.purchase.service.materialdemand.MaterialDemandServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
@Slf4j
public class PurchaseXmRedisConsumersListener extends AbstractRedisStreamMessageListener<CgBpmProcessInstanceStatus> {

    @Resource
    private MaterialDemandService materialDemandService;
    @Override // 监听器
    public void onMessage(CgBpmProcessInstanceStatus message) {
        if (!StrUtil.equals(message.getProcessDefinitionKey(),MaterialDemandServiceImpl.BPM_PROCESS_DEFINITION_KEY)) {
            log.info("[onMessage][消息内容({})]", message);
            return;
        }
        materialDemandService.updateContractAuditStatus(Long.parseLong(message.getBusinessKey()), message.getStatus());
    }

}
